package com.example.batterynotification;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.preference.PreferenceManager;


public class Preferences {
	private static Context context ;
	Preferences(AppContext c){
		context = c.getAppContext() ;
	}

	public static void savePreferences(String key, boolean value) {
		  	        SharedPreferences sharedPreferences = PreferenceManager
		  	                .getDefaultSharedPreferences(context);
		  	        Editor editor = sharedPreferences.edit();
		  	        editor.putBoolean(key, value);
		  	        editor.commit();
		  	    }
		  	 
	  public static void savePreferences(String key, String value) {
					SharedPreferences sharedPreferences = PreferenceManager
					        .getDefaultSharedPreferences(context);
					Editor editor = sharedPreferences.edit();
					editor.putString(key, value);
					editor.commit();
		 	    }
	  
	  public static void savePreferences(String key, int value) {
			SharedPreferences sharedPreferences = PreferenceManager
			        .getDefaultSharedPreferences(context);
			Editor editor = sharedPreferences.edit();
			editor.putInt(key, value);
			editor.commit();
	    }
	  
	public static String getStringPreferences(String key)
	{
		 SharedPreferences sharedPreferences = PreferenceManager
				                 .getDefaultSharedPreferences(context);
		 String name =(String)sharedPreferences.getString(key,null);
		 return name;
		 
	}
	
	public static int getIntPreferences(String key)
	{
		 SharedPreferences sharedPreferences = PreferenceManager
				                 .getDefaultSharedPreferences(context);
		 		
			 int value =(int)sharedPreferences.getInt(key, 0);		 		 
			 return value ;			 		 
	}
	
	public static boolean getBoolPreferences(String key)
	{
		 SharedPreferences sharedPreferences = PreferenceManager
				                 .getDefaultSharedPreferences(context);
		 boolean value =(boolean)sharedPreferences.getBoolean(key,false);
		 return value ;
		 
	}



	
}